//
//  LosDatabaseHelper.m
//  soft
//
//  Created by 陆永亨 on 15/6/4.
//  Copyright (c) 2015年 qixin. All rights reserved.
//

#import "LosDatabaseHelper.h"
__strong static id _sharedObject = nil;
@implementation LosDatabaseHelper
{
    FMDatabaseQueue* queue;
}

-(id) init
{
    self = [super init];
    if(self){
           }
    return self;
}

-(void)creatDatabase
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = documentsDirectory;
    NSString *dbName = [NSString stringWithFormat:@"%@",@"ffmepg.sqlite"];
        
    NSString *dbPath = [path stringByAppendingPathComponent:dbName];
    NSLog(@"%@",dbPath);
        queue = [FMDatabaseQueue databaseQueueWithPath:dbPath];
            
 
  
}

+(LosDatabaseHelper*) sharedInstance
{
    static dispatch_once_t pred = 0;
    
    dispatch_once(&pred, ^{
        _sharedObject = [[self alloc] init];
    });
    return _sharedObject;
}

+(void)delInstance
{
    _sharedObject = nil;
}

-(void) inDatabase:(void(^)(FMDatabase*db))block
{
       [queue inDatabase:^(FMDatabase *db){
        block(db);
       }];
}
@end
